<?php
$redis = new Redis();
$redis->connect('127.0.0.1');
if($redis->exists('data'))
{
    echo "数据库";
    $dbh = new PDO('mysql:host=localhost;dbname=1705php', "root", "root");
    $sql = "select * from `book`";
    $res = $dbh->query($sql);
    $data = $res->fetchAll(2);
    $redis->set('data',json_encode($data));

}else{
    $data=json_decode($redis->get('data'),true);
}
?>
